<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template v-slot:before>
        <zlrt-search :p="ctx">
          <template #tenantId>
            <el-select v-model="ctx.filter.tenantId" placeholder="请选择租户">
              <el-option v-for="ite in tenantOptions" :key="ite.id" :label="ite.name" :value="ite.id" />
            </el-select>
          </template>
        </zlrt-search>
        <div class="tool-bar">
          <el-button type="danger" v-hasPermit="['wms:supplier:del']" icon="Delete" :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()">
            批量删除
          </el-button>
          <span style="float:right">
            <el-button type="success" v-hasPermit="['wms:supplier:list']" :loading="ctx.exportLoading" icon="Download"
              @click="ctx.export()">
              导出
            </el-button>
            <el-button type="primary" v-hasPermit="['wms:supplier:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button>
          </span>
        </div>
      </template>
      <template v-slot:disabled="scope">
        <el-tag :type="scope.row.disabled ? 'danger' : 'success'">{{ ctx.other.getStatusname(scope.row.disabled) }}
        </el-tag>
        <!-- <el-switch v-model="scope.row.disabled" :active-value="false" :inactive-value="true"
          @change="ctx.other.statusChanged(scope.row)" /> -->
      </template>
      <template v-slot:operation="scope">
        <el-button type="primary" v-hasPermit="['wms:supplier:save']" link size="small" icon="Edit"
          @click="ctx.showEdit(scope.row)">
          编辑
        </el-button>
        <el-button type="danger" v-hasPermit="['wms:supplier:del']" link size="small" icon="Delete"
          @click="ctx.del(scope.row.id)">
          删除
        </el-button>
      </template>
      <template v-slot:after>
        <el-dialog v-model="ctx.editVisible" :title="ctx.editAction + ctx.title" width="600px" append-to-body
          :close-on-click-modal="false" @close="ctx.closeEdit()">
          <el-form :ref="(e) => ctx.formRef = e" :model="ctx.editData" :rules="ctx.rules" v-loading="ctx.editLoading"
            label-width="120px" class="demo-ruleForm">
            <el-row>
              <!-- <el-col :span="12">
                <el-form-item label="租户" prop="tenantId">
                  <el-select v-model="ctx.editData.tenantId" placeholder="请选择租户">
                    <el-option v-for="ite in tenantOptions" :key="ite.id" :label="ite.name" :value="ite.id" />
                  </el-select>
                </el-form-item>
              </el-col> -->
              <el-col :span="12">
                <el-form-item label="供应商名称" prop="name">
                  <el-input v-model="ctx.editData.name" placeholder="请输入供应商名称" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="状态" prop="disabled">
                  <el-select v-model="ctx.editData.disabled" placeholder="请选择状态">
                    <el-option v-for="ite in disabledOptions" :key="ite.value" :label="ite.label" :value="ite.value" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人" prop="contactName">
                  <el-input v-model="ctx.editData.contactName" placeholder="请输入联系人" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="联系方式" prop="contactMobile">
                  <el-input v-model="ctx.editData.contactMobile" maxlength="11" placeholder="请输入联系方式" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="联系地址" prop="address">
                  <el-input v-model="ctx.editData.address" placeholder="请输入联系地址" />
                </el-form-item>
              </el-col>

            </el-row>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <el-button @click="ctx.editVisible = false">取消</el-button>
              <el-button type="primary" @click="ctx.save()">确定</el-button>
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>

  </u-container-layout>
</template>

<script lang="ts" src="./supplier">
</script>
